home *** CD-ROM | disk | FTP | other *** search
/ MaxiMac 2000 December / MaxiMac 109.iso / Macworld on CD n°109 / Applications (Mac OS X PB) / ScreenLockerNib-xpb / install next >
Encoding:
Text File  |  2000-10-12  |  2.1 KB  |  95 lines  |  [TEXT/ttxt]

  1. #!/bin/sh
  2. #
  3. # Install an alternative system nib file on Mac OS X Public Beta
  4. # script by Mike Elston <mde@mac.com> 2000/10/12
  5. #
  6.  
  7. # English ScreenSaver preference - new nib file implementing screenlocking
  8. # nib file (c) 2000 Apple Computer, Inc
  9. # modified by Mike Elston <mde@mac.com> 2000/10/11
  10.  
  11. DEST1=/System/Library/Preferences/ScreenSaver.preference
  12. DEST2=Contents/Resources/English.lproj
  13. NIB=ScreenSaverPref.nib
  14. SAVE=ScreenSaverPref_orig.nib
  15. APPNAME="System Preferences"
  16. APP="System Pref"
  17.  
  18. case $1 in
  19. -f) force=yes; shift;;
  20. esac
  21.  
  22. PATH=/bin:/sbin:/usr/sbin:/usr/bin export PATH
  23. err=0
  24. logfile="$0.log"
  25. rm -f $logfile 2>/dev/null
  26. > $logfile
  27. tail -f $logfile &
  28. tailpid=$!
  29. trap "exec >/dev/null 2>&1; sleep 1; kill -HUP $tailpid; exit \$err" 0
  30. exec >$logfile 2>&1
  31.  
  32. # set -x
  33.  
  34. [ `id -u` = 0 ] || {
  35.     echo "You must be the super-user (root) to make this installation"
  36.     err=1; exit $err
  37. }
  38. [ -d ./$NIB ] || {
  39.     cd `expr $0 : '\(.*/\)'` 2>&1
  40.     [ -d ./$NIB ]
  41. } || {
  42.     echo "install: cannot find $NIB to install"
  43.     err=1; exit $err
  44. }
  45. [ -d $DEST1 ] || {
  46.     echo "install: cannot find $DEST1"
  47.     err=1; exit $err
  48. }
  49. [ -d $DEST1/$DEST2 ] || {
  50.     echo "You do not appear to have installed the English language version of" `basename $DEST1`
  51.     err=1; exit $err
  52. }
  53.  
  54. # check whether app is running
  55.  
  56. pid=`ps aux|grep "$APP"|awk '{print $2}'`
  57. [ "$pid" ] && {
  58.     [ "$force" ] || {
  59.     echo "You should quit $APPNAME before installing"
  60.     err=1; exit $err
  61.     }
  62.     echo "... shutting down $APPNAME..."
  63.     kill -HUP $pid 2>&1
  64.     sleep 1 # wait a sec
  65.     [ `ps aux|grep "$APP"|awk '{print $2}'` ] && {
  66.     echo "... failed"
  67.     echo "You should quit $APPNAME before installing"
  68.     err=1; exit $err
  69.     }
  70. }
  71.  
  72. # OK, now we can install
  73.  
  74. [ -d $DEST1/$DEST2/$NIB ] && {
  75.     if [ -d $DEST1/$DEST2/$SAVE ]
  76.     then
  77.     rm -r $DEST1/$DEST2/$NIB 2>&1 || {
  78.         err=1; exit $err
  79.     }
  80.     else
  81.     echo "... saving original nib file"
  82.     mv $DEST1/$DEST2/$NIB $DEST1/$DEST2/$SAVE 2>&1 || {
  83.         err=1; exit $err
  84.     }
  85.     fi
  86. }
  87.  
  88. mv ./$NIB $DEST1/$DEST2/ 2>&1 || {
  89.     err=1; exit $err
  90. }
  91. chown -R 0:0 $DEST1/$DEST2/$NIB 2>&1
  92. chmod -R u=rwX,go=rX $DEST1/$DEST2/$NIB 2>&1
  93.  
  94. echo "Installation of $NIB successful!"
  95.